#include "StickyAction.h"
#include "StickyNotesPlus.h"
#include "StickyNote.h"
#include "StickyNotesDataMgr.h"
#include "StickyNotesUIMgr.h"

#include<vector>

using std::vector;

/** Constructor */
CStickyAction::CStickyAction(int aActionId, const QString &aText, QObject *aParent):QAction(aText, aParent), iActionId(aActionId)
{
}

/** This function returns the action id */
int CStickyAction::GetActionId()
{
    return iActionId;
}

/** This function displays the note associated with this action */
void CStickyAction::ActionTriggered()
{
    vector<CStickyNote*>::iterator notesBeginIterator = CStickyNotesPlus::GetInstance()->GetDataMgr()->GetNotesBeginIterator();

    for(int index=0; index<iActionId; ++index)
        notesBeginIterator++; // Skipping the notes till we reach the note related to the "triggered" action (menu-item)

    if(*notesBeginIterator) // If it is indeed a valid sticky note
    {
        (*notesBeginIterator)->show();
        CStickyNotesPlus::GetInstance()->GetUIMgr()->EvaluateShowNHideAll();
    }
}
